//
//  LSApplyExpertViewController.m
//  LookScore
//
//  Created by warrior on 2018/5/28.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSApplyExpertViewController.h"
#import "LSApplyExpertCell.h"
#import "LSExpertRankModel.h"
@interface LSApplyExpertViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataSource;
@property (nonatomic, strong) NSMutableArray *expertList;

@end

@implementation LSApplyExpertViewController

- (NSArray *)dataSource{
    if (!_dataSource) {
        _dataSource = @[@"",@{@"认证特权":@[@{@"lableText":@"",@"":@""},@{@"lableText":@"",@"":@""},@{@"lableText":@"",@"":@""}]},@""];
    }
    return _dataSource;
}

- (NSMutableArray *)expertList{
    if (!_expertList) {
        _expertList = @[].mutableCopy;
    }
    return _expertList;
}

-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]init];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = [UIColor whiteColor];
//        _tableView.scrollEnabled = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableView;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.translucent = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadExpertList];
    [self initUI];
    
}

- (void)loadExpertList{
    MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
    //    hud.label.text=@"正在请求中...";
    hud.mode=MBProgressHUDModeIndeterminate;
    [LSHttpEnclosureTool GET:LSExpertList parameters:nil resBlock:^(id responseObject) {
        if (responseObject) {
            MyLog(@"ExpertList -- %@",responseObject);
            for (NSDictionary * dict in responseObject[@"ExpertList"]) {
                LSRecommendListModel * model = [LSRecommendListModel mj_objectWithKeyValues:dict];
                [self.expertList addObject:model];
            }
            [hud hideAnimated:YES];
            [self.tableView reloadData];
        }
    }];
}

- (void)initUI{
    self.title = @"申请专家";
    self.view.backgroundColor = LSBackGroundColor;
    
    [self.view addSubview:self.tableView];
    self.tableView.sd_layout
    .leftEqualToView(self.view)
    .topEqualToView(self.view)
    .rightEqualToView(self.view)
    .bottomEqualToView(self.view);
    
//    UIButton *applyBtn = [UIButton new];
//    applyBtn.titleLabel.font=LSFontSize15;
//    [applyBtn setTitle:@"立即申请" forState:UIControlStateNormal];
//    applyBtn.layer.cornerRadius=5;
//    applyBtn.layer.masksToBounds=YES;
//
//    [applyBtn setTitleColor:LSTitleWhiteColor forState:UIControlStateNormal];
//    [applyBtn setBackgroundImage:[CommonClass getImageWithBgColor:LSSubColor7ec5fd] forState:UIControlStateNormal];
//    [applyBtn setBackgroundImage:[CommonClass getImageWithBgColor:LSNavMainColor] forState:UIControlStateHighlighted];
//
//    applyBtn.contentVerticalAlignment=UIControlContentHorizontalAlignmentCenter;
//    [applyBtn addTarget:self action:@selector(clickApplyButton:) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:applyBtn];
//    applyBtn.sd_layout.leftEqualToView(self.view).offset(LSSpaceLeftWidth2).topSpaceToView(self.tableView, 29).rightEqualToView(self.view).offset(-LSSpaceLeftWidth2).heightIs(LSButtonHeight);
}

//- (void)clickApplyButton:(UIButton *)sender{
//    MyLog(@"立即申请");
//    [MBProgressHUD showOnlyMessage:@"请前往网页端操作" afterDelay:1.5f];
//}

#pragma UITableViewDelegate UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        return LSAutoVlaue(88, LSScreenHeight);
    }
    else if (indexPath.row == 1){
        return LSAutoVlaue(138, LSScreenHeight);
    }
    else if (indexPath.row == 2){
        return LSAutoVlaue(230, LSScreenHeight);
    }else{
        return LSAutoVlaue(150, LSScreenHeight);
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        LSApplyExpertCell *cell = [LSApplyExpertCell ApplyExpertCellByTableView:tableView];
        
        return cell;
    }
    else if (indexPath.row == 1){
        LSApprovePrivilegeCell *cell = [LSApprovePrivilegeCell ApprovePrivilegeCellByTableView:tableView];
         cell.dataSource = @[@{@"imageName":@"头像(1)",@"text":@"推介认证标识"},@{@"imageName":@"积分",@"text":@"发推介赚积分"},@{@"imageName":@"礼品兑换",@"text":@"积分赚取收益"}];
        return cell;
    }else if (indexPath.row == 2){
        LSApprovedExpertCell *cell = [LSApprovedExpertCell ApprovedExpertCellByTableView:tableView];
        cell.dataSource = self.expertList;
        return cell;
    }else{
        LSProcesstCell *cell = [LSProcesstCell ProcesstCellByTableView:tableView];
        return cell;
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
